<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Generator</title>
        <script src="../../6-jquery&h5api/js/jquerry-3.5.1.js"></script>
        <script>
            function* test(handle){
                //状态机通用函数
                handle();
                //状态机通用变量
                let a = 1;
                //状态机不通用res  
                let res = yield getData();
                console.log(res);
                handle();
                yield "结束了";
            }
            let gen=test(function(){
                console.log(111);
            })
            gen.next();
            function getData(){
                return $.get('http://47.106.244.1:8099/manager/category/findAllCategory',{},(res)=>{
                    //发起状态机内第二段程序的执行
                    gen.next(res);
                })
            }
        </script>
    </head>
    <body>

    </body>
</html>